//
//  RHAccountViewCell.m
//  RuiHeAppApp
//
//  Created by Jun on 2023/7/20.
//

#import "RHAccountViewCell.h"

@interface RHAccountViewCell()

@property (nonatomic ,strong) QMUILabel *titleLab;

@property (nonatomic ,strong) QMUILabel *contetLab;

@property (nonatomic ,strong) UIView *line;

@property (nonatomic ,strong) UIView *arrow;

@property (nonatomic ,strong) UIView *bgView;
@end

@implementation RHAccountViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        [self setupUI];
    }
    return self;
}

-(void)setTopBorder
{
    self.bgView.layer.cornerRadius = 8;
    self.bgView.qmui_borderColor = kBorderColor;
    self.bgView.qmui_borderWidth = 1;
    self.bgView.qmui_borderPosition = QMUIViewBorderPositionLeft|QMUIViewBorderPositionTop|QMUIViewBorderPositionRight;
    self.bgView.layer.qmui_maskedCorners = QMUILayerMinXMinYCorner|QMUILayerMaxXMinYCorner;
    self.bgView.layer.masksToBounds = YES;
}
-(void)setMiddleBorder
{
    self.bgView.layer.cornerRadius = 0;
    self.bgView.qmui_borderColor = kBorderColor;
    self.bgView.qmui_borderWidth = 1;
    self.bgView.qmui_borderPosition = QMUIViewBorderPositionLeft|QMUIViewBorderPositionRight;
    self.bgView.layer.masksToBounds = YES;
}
-(void)setBottomBorder
{
    self.bgView.layer.cornerRadius = 8;
    self.bgView.qmui_borderColor = kBorderColor;
    self.bgView.qmui_borderWidth = 1;
    self.bgView.qmui_borderPosition = QMUIViewBorderPositionLeft|QMUIViewBorderPositionBottom|QMUIViewBorderPositionRight;
    self.bgView.layer.qmui_maskedCorners = QMUILayerMinXMaxYCorner|QMUILayerMaxXMaxYCorner;
    self.bgView.layer.masksToBounds = YES;
}

- (void)setupUI{
        
    [self setBackgroundColor:UIColor.clearColor];
    [self.contentView setBackgroundColor:UIColor.clearColor];
    
    _bgView = [[UIView alloc] init];
    [_bgView setBackgroundColor:UIColor.whiteColor];
    [self.contentView addSubview:_bgView];
    
    UIView *lineV = [[UIView alloc] init];
    [lineV setBackgroundColor:CFCellLineColor];
    [_bgView addSubview:lineV];
    self.line = lineV;
    
    _titleLab = [[QMUILabel alloc] init];
    [_titleLab setTextAlignment:NSTextAlignmentLeft];
    [_titleLab setTextColor:kCOLOR_HEX(@"3F4443")];
    [_titleLab setFont:[UIFont systemFontOfSize:16]];
    [_bgView addSubview:_titleLab];
    

    _contetLab = [[QMUILabel alloc] init];
    [_contetLab setTextAlignment:NSTextAlignmentRight];
    [_contetLab setTextColor:kCOLOR_HEX(@"#AAAAAA")];
    [_contetLab setFont:[UIFont systemFontOfSize:14]];
    [_bgView addSubview:_contetLab];
    

    UIImageView *arrowV = [[UIImageView alloc] init];
    [arrowV setImage:[UIImage imageNamed:@"cell_arrow"]];
    self.arrow = arrowV;
    [_bgView addSubview:arrowV];
    
    
    kWeakSelf;
    [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.right.mas_offset(-15);
        make.top.bottom.mas_offset(0);
        make.height.mas_equalTo(50);
    }];
    
    [lineV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
        make.right.mas_offset(-15);
        make.height.mas_equalTo(1);
        make.bottom.mas_offset(0);
    }];
    
    [arrowV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(20, 20));
        make.right.mas_offset(-15);
        make.centerY.mas_offset(0);
    }];
    
    [_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(15);
//        make.right.equalTo(weakSelf.contetLab.mas_left).offset(-5);
        make.centerY.mas_offset(0);
        make.height.mas_equalTo(30);
    }];
    
    [_contetLab mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.width.mas_equalTo(170);
        make.right.equalTo(arrowV.mas_left).offset(-5);
        make.centerY.mas_offset(0);
        make.height.mas_equalTo(30);
    }];
    
}


- (void)setTitleStr:(NSString *)titleStr{
    _titleStr = titleStr;
    [self.titleLab setText:_titleStr];
}

- (void)setContentStr:(NSString *)contentStr{
    _contentStr = contentStr;
    [self.contetLab setText:_contentStr];
}


-(void)hideArrow:(BOOL)hide
{
    self.arrow.hidden = hide;
}


-(void)hideLine:(BOOL)hide
{
    self.line.hidden = hide;
}
@end
